/**
 * $Revision: 1.0 $
 * $Author: Eric Yang $
 * $Date: Aug 7, 2007 12:58:02 AM $
 *
 * Author: Eric Yang
 * Date  : Aug 7, 2007 12:58:02 AM
 *
 */
package com.gooex.domain.organization;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Eric Yang
 * @version 1.0
 */
public abstract class AuthorizedObject implements Serializable {
	/** TODO comment */
	private String id;

	/** TODO comment */
	private String name;

	/** TODO comment */
	private boolean isGrantor = false;

	/** TODO comment */
	private List<Authority> authorities = new ArrayList<Authority>();

	/** TODO comment */
	public boolean equals(Object obj) {
		String name1 = this.getClass().getName();
		String name2 = obj.getClass().getName();
		if (name1.startsWith(name2) || name2.startsWith(name1)) {
			return this.getName().equals(((AuthorizedObject) obj).getName());
		}
		return false;
	}

	public boolean hasAuthority(Authority authority) {
		return authorities.contains(authority);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Authority> getAuthorities() {
		return authorities;
	}

	public void setAuthorities(List<Authority> authorities) {
		this.authorities = authorities;
	}

	public boolean isGrantor() {
		return isGrantor;
	}

	public void setGrantor(boolean isGrantor) {
		this.isGrantor = isGrantor;
	}
}
